{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 第五次练习"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "+ 请务必交到exer5文件夹下，**谢绝交到master下**\n",
    "+ 请不要改动任何文件，拜托\n",
    "+ 请在11月7日前提交。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "请写一下姓名和学号：\n",
    "+ 姓名  廖之奇\n",
    "+ 学号  0162452"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 题目一、贫困户模型\n",
    "+ 创建一个类，包含贫困户的义务教育保障、住房安全、饮水安全、肉蛋奶豆的四个属性\n",
    "+ 包含一个是否贫困的预测，如果四个属性有两个以上没有保障（>2)则输出为贫困户\n",
    "+ 对贫困户，采取相应措施（输入参数）对其进行帮扶，使其脱贫\n",
    "+ 至少生成三个实例\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "这不是贫困户\n",
      "这是贫困户\n",
      "扶持教育\n",
      "扶持住房\n",
      "保障饮水\n",
      "这不是贫困户\n"
     ]
    }
   ],
   "source": [
    "class poor_households():\n",
    "    def __init__(self,education,housing,water,diet):\n",
    "        self.education = education\n",
    "        self.housing = housing\n",
    "        self.water = water\n",
    "        self.diet = diet\n",
    "        \n",
    "    def yiwujiaoyu(self,year):\n",
    "        if year >= 9:\n",
    "            self.education=True\n",
    "        else:\n",
    "            self.education=False\n",
    "            \n",
    "    def zhufang(self,types):\n",
    "        if types == \"楼房\" :\n",
    "            self.housing=True\n",
    "        else:\n",
    "            self.housing=False\n",
    "            \n",
    "    def yinshuizhiliang(self,quality):\n",
    "        if quality == \"合格\":\n",
    "            self.water=True\n",
    "        else:\n",
    "            self.water=False\n",
    "            \n",
    "    def roudandounai(self,kinds):\n",
    "        if kinds >= 3:\n",
    "            self.diet=True\n",
    "        else :\n",
    "            self.diet=False\n",
    "    \n",
    "def safeguard(self):\n",
    "    sum=0\n",
    "    if self.education==False:\n",
    "        sum+=1\n",
    "    if self.housing==False:\n",
    "        sum+=1\n",
    "    if self.water==False:\n",
    "        sum+=1\n",
    "    if self.diet==False:\n",
    "        sum+=1\n",
    "    if sum>2:\n",
    "        print(\"这是贫困户\")\n",
    "        if self.education==False:\n",
    "            print(\"扶持教育\")\n",
    "        if self.housing==False:\n",
    "            print(\"扶持住房\")\n",
    "        if self.water==False:\n",
    "            print(\"保障饮水\")\n",
    "        if self.diet==False:\n",
    "            print(\"保障饮食\")  \n",
    "    else:\n",
    "        print(\"这不是贫困户\")\n",
    "            \n",
    "            \n",
    "A=poor_households(False,False,False,False)\n",
    "A.yiwujiaoyu(12)\n",
    "A.zhufang(\"楼房\")\n",
    "A.yinshuizhiliang(\"合格\")\n",
    "A.roudandounai(1)\n",
    "safeguard(A)\n",
    "\n",
    "B=poor_households(False,True,False,False)\n",
    "B.yiwujiaoyu(2)\n",
    "B.zhufang(\"危房\")\n",
    "B.yinshuizhiliang(\"不合格\")\n",
    "B.roudandounai(3)\n",
    "safeguard(B)\n",
    "\n",
    "C=poor_households(False,False,False,False)\n",
    "C.yiwujiaoyu(6)\n",
    "C.zhufang(\"楼房\")\n",
    "C.yinshuizhiliang(\"合格\")\n",
    "C.roudandounai(3)\n",
    "safeguard(C)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 题目二: 学生信息\n",
    "+ 创建一个类，包含姓名、分数、睡眠时间三个属性\n",
    "+ 包含一个胖瘦的预测，如果分数>90，且睡眠时间少于6小时，输出“BMI可能偏大”，否则输出“体重正常”\n",
    "+ 为使得标准（90分、6小时）可以调整，标准应设为输入的参数\n",
    "+ 至少生成三个实例"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "BIM可能偏大\n",
      "BIM可能偏大\n",
      "体重正常\n"
     ]
    }
   ],
   "source": [
    "class student(object):\n",
    "    def __init__(self, name, score ,hours):\n",
    "        self.name = name\n",
    "        self.score = score\n",
    "        self.hours = hours\n",
    "        \n",
    "    def standard(self,x,y):\n",
    "        if self.score > x and self.hours < y :\n",
    "            print(\"BIM可能偏大\")\n",
    "            \n",
    "        else:\n",
    "            print(\"体重正常\")\n",
    "            \n",
    "            \n",
    "example1=student(\"A\",91,4)\n",
    "example2=student(\"B\",95,5)\n",
    "example3=student(\"C\",85,7)\n",
    "\n",
    "example1.standard(90,6)\n",
    "example2.standard(90,6)\n",
    "example3.standard(90,6)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 题目三：“跑步社”成员类\n",
    "+ 创建一个“跑步社”成员类，以学生信息类为父类\n",
    "+ 添加一个属性为跑步\n",
    "+ 如果跑步时间大于30分钟，如果之前预测为“BMI可能偏大”，则输出为“趋向正常”\n",
    "+ 至少生成三个实例"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "趋向正常\n",
      "BIM可能偏大\n",
      "体重正常\n"
     ]
    }
   ],
   "source": [
    "class member(student):\n",
    "    def __init__(self,name,score,hours,run):\n",
    "        super().__init__(name, score ,hours)\n",
    "        self.run=run\n",
    "    def standard(self,x,y):\n",
    "        if self.score > x and self.hours < y :\n",
    "            if self.run>30:\n",
    "                print(\"趋向正常\")\n",
    "            else:\n",
    "                print(\"BIM可能偏大\")\n",
    "            \n",
    "        else:\n",
    "            print(\"体重正常\")\n",
    "\n",
    "\n",
    "example1=member(\"A\",91,4,31)\n",
    "example2=member(\"B\",95,5,20)\n",
    "example3=member(\"C\",85,7,25)\n",
    "\n",
    "example1.standard(90,6)\n",
    "example2.standard(90,6)\n",
    "example3.standard(90,6)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
